<%@ page import="com.sun.java.util.jar.pack.Package" %>
<%@ page import="java.sql.*" %>
<%@ page import="org.apache.catalina.User" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: 美美美
  Date: 2018/4/3
  Time: 16:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>插入数据</title>
</head>
<body>
<%


    String name = request.getParameter("username");
    String password = request.getParameter("password");

    List<User> userList = new ArrayList<User>();

    Connection connection = null;
    Statement statement = null;

    String sql = "insert into t_user VALUES (name,password)" +
            "values('"+name+"','"+password+"')";
    statement.execute(sql);

    Class.forName("com.mysql.jdbc.Driver");

    connection = DriverManager.getConnection(
            "jdbc:mysql://localhost:3306/sctu_javaweb_2018",
            "root",
            "251807680wmh"
    );

    statement = connection.createStatement();

    statement.execute(sql);
    statement.close();
    connection.close();

    out.write("<h1>add user successful!</h1>");
    out.write("<a href='index.jsp'>return index</a>");

%>

</body>
</html>
